using System;

namespace ZFramework.Runtime.DataCenter
{
    public sealed partial class DataCenterManager : FrameworkManagerBase
    {
        public class DataInfo : IReference
        {
            private DataCenter _mDataCenter;
            private DataStatus m_Status;
            private int m_Priority;

            public DataInfo()
            {
                _mDataCenter = null;
                m_Status = DataStatus.None;
            }

            public DataCenter DataCenter
            {
                get { return _mDataCenter; }
            }

            public DataStatus Status
            {
                get { return m_Status; }
                set { m_Status = value; }
            }

            public int Priority
            {
                get { return m_Priority; }
                set { m_Priority = value; }
            }

            public static DataInfo Create(DataCenter dataCenter)
            {
                if (dataCenter == null)
                {
                    throw new Exception("Data is invalid.");
                }

                DataInfo dataInfo = ReferencePool.Acquire<DataInfo>();
                dataInfo._mDataCenter = dataCenter;
                dataInfo.m_Status = DataStatus.None;
                dataInfo.Priority = 0;
                return dataInfo;
            }

            public void Clear()
            {
                _mDataCenter = null;
                m_Status = DataStatus.None;
                Priority = 0;
            }
        }
    }
}
